﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="grdRequisitoProjeto.ascx.cs" Inherits="QFD.View.RequisitoProjeto.grdRequisitoProjeto" %>
<%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
<%@ Register Src="~/View/RequisitoProjeto/frmRequisitoProjeto.ascx" TagName="RequisitoProjeto" TagPrefix="UC8" %>

<ext:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server">
</ext:ScriptManagerProxy>

<script type="text/javascript">
    function alertMessage() {
        GridPanel = eval('<%=GridRequisitoProjeto.ClientID%>');
        if (GridPanel.hasSelection())
            return "Confirma Exclusão? <br> <b>" + GridPanel.getSelectionModel().getSelected().data.CDREQPROJETO + "</b>";
    }
</script>

<ext:DesktopWindow ID="WinGrdRequisitoProjeto" runat="server" Icon="ADD"
 Title="Requisitos de Projeto" Width="500" Height="400">
 <Body>
     <ext:Store ID="StoreRequisitoProjeto" runat="server" OnRefreshData="Refresh" RefreshAfterSaving="Auto">
         <Reader>
             <ext:JsonReader>
                 <Fields>
                     <ext:RecordField Name="CDREQPROJETO" />
                     <ext:RecordField Name="VLSEMTELHADO" />
                     <ext:RecordField Name="VLCOMTELHADO" />
                     <ext:RecordField Name="CDMETA" />
                     <ext:RecordField Name="DSMETA" />
                     <ext:RecordField Name="CDPROJETO" />
                     <ext:RecordField Name="REQPAI" />
                     <ext:RecordField Name="FGREQPROJETO" />
                     <ext:RecordField Name="DSREQUISITO" />
                     <ext:RecordField Name="CDREQUISITO" />
                     <ext:RecordField Name="CDPAI" />
                     <ext:RecordField Name="DESPAI" />
                 </Fields>
             </ext:JsonReader>
         </Reader>
     </ext:Store>

     <ext:FitLayout ID="Layout1" runat="server">

     <ext:GridPanel ID="GridRequisitoProjeto"
     runat="Server"
     StoreID="StoreRequisitoProjeto"
     Width="600"
     Height="290"
     AutoExpandColumn="DSREQUISITO"
     >
     
         <TopBar>
             <ext:Toolbar ID="Tollbar1" runat="server">
                 <Items>

                     <ext:ToolbarButton ID="btnAddStoreRequisitoProjeto" runat="server" Icon="ADD">
                         <Listeners>
                             <Click Handler="newRequisitoProjeto();" />
                         </Listeners>
                     </ext:ToolbarButton>

                     <ext:ToolbarButton ID="btnExcluirRequisitoProjeto" runat="server" Icon="Cross" Enabled="false">
                         <AjaxEvents>
                             <Click OnEvent="deleteRequisitoProjeto">
                                 <Confirmation ConfirmRequest="true" Title="Alerta" BeforeConfirm="config.confirmation.message = alertMessage()" />
                                 <ExtraParams>
                                     <ext:Parameter Name="id" Value="#{GridRequisitoProjeto}.getSelectionModel().hasSelection() ? #{GridRequisitoProjeto}.getSelectionModel().getSelected().data.CDREQPROJETO : -1"
                                         Mode="Raw" />
                                 </ExtraParams>
                             </Click>
                         </AjaxEvents>
                         <ToolTips>
                             <ext:ToolTip ID="ToolTip3" runat="server" Html="Excluir Requisito de Projeto">
                             </ext:ToolTip>
                         </ToolTips>
                     </ext:ToolbarButton>
                 </Items>
             </ext:Toolbar>
         </TopBar>

         <ColumnModel ID="ColumnModel1" runat="server">
             <Columns>
                 <ext:Column ColumnID="DSREQUISITO" Header="Requisito" Width="160" Sortable="true"
                     DataIndex="DSREQUISITO" />
                 <ext:Column ColumnID="REQPAI" Header="Requisito Pai" Width="160" Sortable="true"
                     DataIndex="DESPAI" />
                 <ext:Column ColumnID="DSMETA" Header="Valor Meta" Width="160" Sortable="true"
                     DataIndex="DSMETA" />

                 <ext:Column ColumnID="CDREQPROJETO" Header="Editar" Width="100" Sortable="true"
                     DataIndex="CDREQPROJETO" Fixed="true" MenuDisabled="true" Align="Center">
                     <Renderer Fn="imgEditar" />
                 </ext:Column>
             </Columns>
         </ColumnModel>

         <SelectionModel>
             <ext:RowSelectionModel ID="RowSelectionModel1" runat="server">
                 <Listeners>
                     <RowSelect Handler="#{btnExcluirRequisitoProjeto}.enable()" />
                     <RowDeselect Handler="if (!#{GridRequisitoProjeto}.hasSelection()) {#{btnExcluirRequisitoProjeto}.disable()}" />
                 </Listeners>
             </ext:RowSelectionModel>
         </SelectionModel>

         <AjaxEvents>
             <CellDblClick OnEvent="EditarRequisitoProjeto" Failure="Ext.MessageBox.alert('Erro Leitura BD', 'Error ocorreu no Ajax Event!');">
                 <EventMask ShowMask="true" Msg="Carregando..." Target="CustomTarget" CustomTarget="={#{GridRequisitoProjeto}.body}" />
                 <ExtraParams>
                     <ext:Parameter Name="id" Value="#{GridRequisitoProjeto}.getSelectionModel().getSelected().data.CDREQPROJETO"
                         Mode="Raw" />
                 </ExtraParams>
             </CellDblClick>
         </AjaxEvents>

         <LoadMask ShowMask="true" />
         <SaveMask ShowMask="true" />
         <BottomBar>
             <ext:PagingToolbar ID="PagingToolBar1" runat="server" PageSize="10" StoreID="StoreRequisitoProjeto" />
         </BottomBar>

     </ext:GridPanel>     
  </ext:FitLayout>

    <UC8:RequisitoProjeto ID="uc8" runat="Server" />

 </Body>
</ext:DesktopWindow>